<?php
namespace app\common\model;
use think\Model;

class FileModel extends Model{
    protected  $name = 'file';
    protected  $pk   = 'file_id';

    public static function onBeforeInsert($model)
    {
        $model->set("create_ip", request()->ip());
    }
    public function category()
    {
        return $this->belongsTo(FileCategoryModel::class,'category_id')->bind(['category_name']);
    }
    public function setFileNameAttr($value){
        return str_replace('稿定', '', $value);
    }
}